/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.yihu.wlyy.entity.patient.PatientReservationDoctor;

public interface PatientReservationDoctorDao extends PagingAndSortingRepository<PatientReservationDoctor, Long>, JpaSpecificationExecutor<PatientReservationDoctor> {

	@Query("select a from PatientReservationDoctor a where a.patient = ?1 order by a.id desc")
	List<PatientReservationDoctor> findByPatient(String patient);

	@Modifying
	@Query("delete PatientReservationDoctor a where a.patient = ?1 and a.orgCode = ?2 and a.deptCode = ?3 and a.doctorCode = ?4")
	int deleteByPatient(String patient, String orgCode, String deptCode, String doctorCode);

}
